package m.store.action;

import m.base.action.BaseAction;
import m.base.util.LevelUtil;
import m.base.util.PowerUtil;
import m.common.action.ActionMeta;
import m.common.action.VueResult;
import m.common.model.util.QueryCondition;
import m.common.model.util.QueryOrder;
import m.html.VueListResult;
import m.html.list.EventType;
import m.html.list.ListCount;
import m.html.list.ListEvent;
import m.store.model.GoodsOutVirtualStock;
import m.store.model.RepositoryInfo;

@ActionMeta(name = "store/goodsOutVirtualStock")
public class GoodsOutVirtualStockAction extends BaseAction {

    /*
     * 调货详情
     */
    public VueResult recordList() throws Exception {
        VueListResult result=getVueListResult("调货详情", GoodsOutVirtualStock.class,actionUrl("recordList"));
        result.setFunction(LevelUtil.exportFunc(),false);
        result.setHeight(-1);
        result.addCol(toLinkColumn("调货客户", "record.record.stock.guest.name", 150, true,
            new ListEvent(actionUrl(GuestInfoAction.class,"toView"), EventType.MODAL,1300)
                .addParam("model.oid","record.record.stock.guest.oid")
        ));
        result.addCol(toTextColumn("仓库", "repository.oid", 100, true).setDictType(RepositoryInfo.class, PowerUtil.getSessionStoreOid()));
        result.addCol(toLinkColumn("商品名称", "record.goods.name", 200, true,
            new ListEvent("page/store/storeGoods.js", EventType.MODAL,600)
                .addParam("oid","record.goods.oid")
        ));
        result.addCol(toNumberColumn("单价", "price", 100, true).setGroupTitle("调货").setCount(ListCount.NONE));
        result.addCol(toIntegerColumn("数量", "stockNum", 100, true).setGroupTitle("调货"));
        result.addCol(toNumberColumn("总优惠", "preferential", 100, true).setGroupTitle("调货"));
        result.addCol(toNumberColumn("单价", "preferentialPrice", 100, true).setGroupTitle("优惠后").setCount(ListCount.NONE));
        result.addCol(toNumberColumn("金额", "stockAmount", 100, true).setGroupTitle("优惠后"));
        result.addCol(toTextColumn("备注", "remark", 100, true));
        //排序 result.addOrder
        //查询条件 result.addCondition
        result.addCondition(QueryCondition.eq("record.sale.oid",getParamsValue("record.sale.oid")));
//        result.addOrder(QueryOrder.asc("oid"));
        return result;
    }
}
